package com.example.demo.day0229;

import com.example.demo.day0225.Exception;


import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class DemoOutput {
    public static void main(String[] args) throws  IOException {
        DemoOutput.testFileOutputStream();

    }

    public static void testFileOutputStream() throws IOException {
        try {
            FileOutputStream out = new FileOutputStream("D:/File/tt4.txt");//文件字节输出流，指定向tt4文件输出
            String str = "asdf";//在写入时目录下有同名文件将被覆盖
            out.write(str.getBytes());//把数据写到内存
            out.flush();//把内存的数据写道硬盘
            out.close();//关闭流

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
